<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Swing Twist Decomposition &#8212; cmt  documentation</title>
    <link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Curve Control Creator" href="control.html" />
    <link rel="prev" title="Space Switching" href="spaceswitch.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript" src="../_static/js/jquery-1.11.0.min.js "></script>
<script type="text/javascript" src="../_static/js/jquery-fix.js "></script>
<script type="text/javascript" src="../_static/bootstrap-3.3.7/js/bootstrap.min.js "></script>
<script type="text/javascript" src="../_static/bootstrap-sphinx.js "></script>

  </head><body>

  <div id="navbar" class="navbar navbar-default navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="../index.html">
          cmt</a>
        <span class="navbar-text navbar-version pull-left"><b></b></span>
      </div>

        <div class="collapse navbar-collapse nav-collapse">
          <ul class="nav navbar-nav">
            
            
              <li class="dropdown globaltoc-container">
  <a role="button"
     id="dLabelGlobalToc"
     data-toggle="dropdown"
     data-target="#"
     href="../index.html">Site <b class="caret"></b></a>
  <ul class="dropdown-menu globaltoc"
      role="menu"
      aria-labelledby="dLabelGlobalToc"><ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation Instructions</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../rigging.html">Rigging Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dge.html">Dependency Graph Expressions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../customwidgets.html">Custom Widgets</a></li>
</ul>
</ul>
</li>
              
                <li class="dropdown">
  <a role="button"
     id="dLabelLocalToc"
     data-toggle="dropdown"
     data-target="#"
     href="#">Page <b class="caret"></b></a>
  <ul class="dropdown-menu localtoc"
      role="menu"
      aria-labelledby="dLabelLocalToc"><ul>
<li><a class="reference internal" href="#">Swing Twist Decomposition</a><ul>
<li><a class="reference internal" href="#example-usage">Example Usage</a></li>
<li><a class="reference internal" href="#network-with-the-plug-in">Network with the Plug-in</a></li>
<li><a class="reference internal" href="#network-without-the-plug-in">Network without the Plug-in</a></li>
</ul>
</li>
</ul>
</ul>
</li>
              
            
            
              
                
  <li>
    <a href="spaceswitch.html" title="Previous Chapter: Space Switching"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm hidden-tablet">&laquo; Space Switching</span>
    </a>
  </li>
  <li>
    <a href="control.html" title="Next Chapter: Curve Control Creator"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm hidden-tablet">Curve Control Creator &raquo;</span>
    </a>
  </li>
              
            
            
            
            
              <li class="hidden-sm">
<div id="sourcelink">
  <a href="../_sources/rig/swingtwist.rst.txt"
     rel="nofollow">Source</a>
</div></li>
            
          </ul>

          
            
<form class="navbar-form navbar-right" action="../search.html" method="get">
 <div class="form-group">
  <input type="text" name="q" class="form-control" placeholder="Search" />
 </div>
  <input type="hidden" name="check_keywords" value="yes" />
  <input type="hidden" name="area" value="default" />
</form>
          
        </div>
    </div>
  </div>

<div class="container">
  <div class="row">
    <div class="body col-md-12 content" role="main">
      
  <div class="section" id="module-cmt.rig.swingtwist">
<span id="swing-twist-decomposition"></span><h1>Swing Twist Decomposition<a class="headerlink" href="#module-cmt.rig.swingtwist" title="Permalink to this headline">¶</a></h1>
<p>Creates a node network to extract swing/twist rotation of a transform to drive
another transforms offsetParentMatrix.</p>
<p>The network calculates the local rotation swing and twist offset around the specified
twist axis relative to the local rest orientation.  This allows users to specify how
much swing and twist they want to propagate to another transform.  Uses include driving
an upper arm twist joint from the shoulder and driving forearm twist joints from the
wrist.</p>
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
  <iframe src="https://www.youtube.com/embed/12tyQc93Y7A" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" allowfullscreen title="YouTube Video"></iframe>
</div><p>Since the network uses quaternions, partial swing and twist values between 0.0 and 1.0
will see a flip when the driver transform rotates past 180 degrees.</p>
<p>The setup can either be made with several standard Maya nodes, or the compiled plug-in
can be used to create a single node. Setting cmt.settings.ENABLE_PLUGINS to False will
use vanilla Maya nodes. Otherwise, the compiled plug-in will be used.</p>
<div class="section" id="example-usage">
<h2>Example Usage<a class="headerlink" href="#example-usage" title="Permalink to this headline">¶</a></h2>
<p>The twist decomposition network can be accessed in the cmt menu:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">CMT</span> <span class="o">&gt;</span> <span class="n">Rigging</span> <span class="o">&gt;</span> <span class="n">Connect</span> <span class="n">Twist</span> <span class="n">Joint</span>
</pre></div>
</div>
<p>Twist child of shoulder:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shoulder</span>
  <span class="o">|-</span> <span class="n">twist_joint1</span>
  <span class="o">|-</span> <span class="n">twist_joint2</span>
  <span class="o">|-</span> <span class="n">elbow</span>

<span class="n">create_swing_twist</span><span class="p">(</span><span class="n">shoulder</span><span class="p">,</span> <span class="n">twist_joint1</span><span class="p">,</span> <span class="n">twist_weight</span><span class="o">=-</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">swing_weight</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
<span class="n">create_swing_twist</span><span class="p">(</span><span class="n">shoulder</span><span class="p">,</span> <span class="n">twist_joint2</span><span class="p">,</span> <span class="n">twist_weight</span><span class="o">=-</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">swing_weight</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
</pre></div>
</div>
<p>Twist forearm from wrist:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">elbow</span>
  <span class="o">|-</span> <span class="n">twist_joint1</span>
  <span class="o">|-</span> <span class="n">twist_joint2</span>
  <span class="o">|-</span> <span class="n">wrist</span>

<span class="n">create_swing_twist</span><span class="p">(</span><span class="n">wrist</span><span class="p">,</span> <span class="n">twist_joint1</span><span class="p">,</span> <span class="n">twist_weight</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">swing_weight</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
<span class="n">create_swing_twist</span><span class="p">(</span><span class="n">wrist</span><span class="p">,</span> <span class="n">twist_joint2</span><span class="p">,</span> <span class="n">twist_weight</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">swing_weight</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
</pre></div>
</div>
<p>Use no plugins:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">cmt.settings</span> <span class="k">as</span> <span class="nn">settings</span>
<span class="n">settings</span><span class="o">.</span><span class="n">ENABLE_PLUGINS</span> <span class="o">=</span> <span class="kc">False</span>
<span class="n">create_swing_twist</span><span class="p">(</span><span class="n">wrist</span><span class="p">,</span> <span class="n">twist_joint1</span><span class="p">,</span> <span class="n">twist_weight</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">swing_weight</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
<span class="n">create_swing_twist</span><span class="p">(</span><span class="n">wrist</span><span class="p">,</span> <span class="n">twist_joint2</span><span class="p">,</span> <span class="n">twist_weight</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">swing_weight</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
</pre></div>
</div>
<dl class="py function">
<dt id="cmt.rig.swingtwist.create_swing_twist">
<code class="sig-prename descclassname">cmt.rig.swingtwist.</code><code class="sig-name descname">create_swing_twist</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">driver</span></em>, <em class="sig-param"><span class="n">driven</span></em>, <em class="sig-param"><span class="n">twist_weight</span><span class="o">=</span><span class="default_value">1.0</span></em>, <em class="sig-param"><span class="n">swing_weight</span><span class="o">=</span><span class="default_value">1.0</span></em>, <em class="sig-param"><span class="n">twist_axis</span><span class="o">=</span><span class="default_value">0</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/cmt/rig/swingtwist.html#create_swing_twist"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#cmt.rig.swingtwist.create_swing_twist" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a node network to drive a transforms offsetParentMatrix from the
decomposed swing/twist of another transform.</p>
<p>Setting cmt.settings.ENABLE_PLUGINS to False will use vanilla Maya nodes. Otherwise,
the compiled plug-in will be used.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>driver</strong> – Driver transform</p></li>
<li><p><strong>driven</strong> – Driven transform</p></li>
<li><p><strong>twist_weight</strong> – -1 to 1 twist scalar</p></li>
<li><p><strong>swing_weight</strong> – -1 to 1 swing scalar</p></li>
<li><p><strong>twist_axis</strong> – Local twist axis on driver (0: X, 1: Y, 2: Z)</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</div>
<div class="section" id="network-with-the-plug-in">
<h2>Network with the Plug-in<a class="headerlink" href="#network-with-the-plug-in" title="Permalink to this headline">¶</a></h2>
<img alt="../_images/swingtwist_plugin.png" src="../_images/swingtwist_plugin.png" />
</div>
<div class="section" id="network-without-the-plug-in">
<h2>Network without the Plug-in<a class="headerlink" href="#network-without-the-plug-in" title="Permalink to this headline">¶</a></h2>
<img alt="../_images/swingtwist.png" src="../_images/swingtwist.png" />
</div>
</div>


    </div>
      
  </div>
</div>
<footer class="footer">
  <div class="container">
    <p class="pull-right">
      <a href="#">Back to top</a>
      
    </p>
    <p>
        &copy; Copyright 2018, Chad Vernon.<br/>
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.1.2.<br/>
    </p>
  </div>
</footer>
  </body>
</html>